
Alesk Remo
Amarr Corpus Prometheus
|
Posted - 2008.12.01 07:32:00 -
[1]
Edited by: Alesk Remo on 01/12/2008 07:33:11 First of all - thanks for a really nice class.
Secondly, I've made some modifications to make the cache MySQL dependent (as a choice). However, all this change does is store the XML data into a database table for easy and fast access.
The database requirements: The database requires a single table, api_cache, which has three columns, CacheID, CacheLocation and CacheValue.
CacheID is an indexed Primary Key field which I use in order to speed up requests to the cache table.
CacheLocation stores a unique path like structure similarly to that which is currently used as the path that is created by the getCacheFile function. In fact it uses the same function except it replaces the "/" slashes with "-" hyphens.
CacheValue stores the XML data in an HTML encoded format (using the htmlentities function) which has been fetched by the API class.
Quote:
CREATE TABLE `api_cache` ( `CacheID` int(11) NOT NULL auto_increment, `CacheLocation` longtext character set latin1, `CacheValue` longtext character set latin1, PRIMARY KEY (`CacheID`), FULLTEXT KEY `CacheLocation` (`CacheLocation`,`CacheValue`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1 ;
The code changes: The only file affected with the changes is the class.api.php file.
The code changes only affect those function which access and write/update the cache. Static variables are also created along with a property function to specify the database parameters.
There is a fair amount of changes to the function which would take about 5 replies. To simplify this I've linked to the modified file so that you can download and have a look at the code.
Linkage
I have no doubt that there are better ways to use a database with this class, however these modification basically just replace the use of the directory store as a cache with a database store. All XML is encoded when stored and then decoded again when accessed.
I would like to hear opinions and feedback on this as well as if anyone has any ideas to improve on this.
Regards,
Alesk Remo
|